from django.db import models

# Create your models here.
class memberinfo(models.Model):
    """用户信息表"""
    name = models.CharField(max_length=32, verbose_name="姓名")
    phone = models.CharField(max_length=32, verbose_name="电话")
    balance = models.CharField(max_length=32, verbose_name="余额", default='0')
    isty_choices = (
        (0, "已停用"),
        (1, "启用")
    )
    isty = models.IntegerField(choices=isty_choices, verbose_name="状态", default= 1)

class balanceinfo(models.Model):
    balance = models.CharField(max_length=32, verbose_name="余额")
    newbalance = models.CharField(max_length=32, verbose_name="充值金额")
    member = models.ForeignKey(to="memberinfo", to_field="id", on_delete=models.CASCADE, verbose_name="关联会员")
    data = models.DateTimeField( verbose_name="充值时间", auto_now=True )


class yardinfo(models.Model):
    name = models.CharField(max_length=32, verbose_name="场地名")
    charge = (
        (0, "次数"),
        (1, "小时")
    )
    charge  = models.IntegerField(choices=charge, verbose_name="收费模式", default= 1)
    charge_num = models.CharField(max_length=32, verbose_name="收费金额")
    isty_choices = (
        (0, "已使用"),
        (1, "未使用")
    )
    isty = models.IntegerField( choices=isty_choices, verbose_name="状态", default=1 )
    starttime = models.DateTimeField( verbose_name="开始时间", blank=True, null=True)

class saleinfo(models.Model):
    starttime = models.DateTimeField( verbose_name="开始时间")
    endtime = models.DateTimeField( verbose_name="结束时间")
    price =  models.CharField(max_length=32, verbose_name="结算金额")
    member = models.ForeignKey( to="memberinfo", to_field="id", on_delete=models.CASCADE, verbose_name="关联会员",blank=True,null=True )
    yard = models.ForeignKey(to="yardinfo",to_field="id",on_delete=models.CASCADE)